/**
 * 
 */
package org.gigi.security.repository.hibernate;

import java.util.List;

import org.gigi.security.domain.Authority;
import org.gigi.security.repository.AuthorityRepository;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

/**
 * 
 *
 * @author Eugene Wang 2011-9-13
 * @see
 */
@Repository
public class HibernateAuthorityRepository extends AbstractHibernateRepository implements AuthorityRepository {
	/*
	 * (non-Javadoc)
	 * @see org.gigi.security.repository.AuthorityRepository#load(java.lang.String)
	 */
	@Override
	public Authority load(String code) {
		return (Authority) getSession().load(Authority.class, code);
	}

	/* (non-Javadoc)
	 * @see org.gigi.security.repository.AuthorityRepository#findAll()
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<Authority> findAll() {
		Query query = getSession().createQuery("select auth from Authority auth");
		return query.list();
	}
	
}
